package com.hnkywl.sts.service.jsgl;

import com.hnkywl.sts.dao.cggl.GlfyDao;
import com.hnkywl.sts.dao.jsgl.*;
import com.hnkywl.sts.dao.organ.EjzhDao;
import com.hnkywl.sts.dao.sfgl.SkshDao;
import com.hnkywl.sts.dao.xsgl.DfkxsdDao;
import com.hnkywl.sts.dao.xsgl.XsmxDao;
import com.hnkywl.sts.entity.cggl.Jsd;
import com.hnkywl.sts.service.base.BmService;
import com.hnkywl.sts.util.BaseUtils;
import net.ruixin.orm.hibernate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by HL on 2015/9/22.
 */
@Service
public class FpcxService {
    private FpcxDao fpcxDao;

    @Transactional
    public String findAllfpcx(Integer type, Integer zt, String jsdh, Date sqrqStart, Date sqrqEnd, Long glqyId, String glqyQc, Long gsId, String gsJc, Long fpzlId, int pageNo, int pageSize, Long ywgsID) {
        if ("".equals(gsJc)) {
            gsId = null;
        }
        Page<Jsd> fpPage = this.fpcxDao.findfpcxList(type, zt, jsdh, sqrqStart, sqrqEnd, glqyId, glqyQc, gsId, gsJc, fpzlId, pageNo, pageSize, ywgsID);
        List<Jsd> fpList = fpPage.getResult() == null ? new ArrayList<Jsd>() : fpPage.getResult();
        String fpJson = BaseUtils.fetchCollectionToJson(fpList, "id", "jsdh", "sqrq", "glqy.qyfr.nsh", "type", "glqy.id", "glqy.qc", "fpze", "ddfy", "fpzl", "hm", "sqr.id", "sqr.xm", "gs.id", "gs.jc", "cggs.id", "cggs.jc", "shzt", "kprq", "kpr.id", "kpr.xm", "sftzd", "zt", "yjsd.id", "swse");
        return "{\"total\":" + fpPage.getTotalCount() + ",\"rows\":[" + fpJson + "]}";
    }


    @Autowired
    public void setFpcxDao(FpcxDao fpcxDao) {
        this.fpcxDao = fpcxDao;
    }
}
